package edu.itesm.rm.utils {
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.display.BitmapData;
	/**
	 * @author aldoreyes
	 */
	public class MaterialUtils {
		
		public static function generateSequence(source:BitmapData, width:Number, height:Number, frames:int = 1, copies:int = 1, displaceSourceY:Number = 0):Array{
			var toReturn:Array = new Array();
			var frame:BitmapData = new BitmapData(width, height, true,0);
			var srcRect:Rectangle = new Rectangle(0,displaceSourceY,width,height);
			var destPoint:Point = new Point();
			
			for (var i : int = 0; i < frames; i++) {
				frame = frame.clone();
				srcRect.x = i*width;
				frame.copyPixels(source, srcRect, destPoint);
				for (var j : int = 0; j < copies; j++) {
					toReturn.push(frame);
				}				
			}
			
			toReturn.concat(toReturn.reverse());
			
			return toReturn;
		}
	}
}
